import { get } from '@/utils/request'
import { ref, onMounted } from 'vue'

const useUserList = (pageNum = 1) => {
  const data = ref([])

  const loadData = async (page) => {
    let ret = await get(`/api/users?page=${page}`)
    data.value = ret.data
  }

  onMounted(() => {
    loadData(pageNum)
  })

  return [data, loadData]
}

export default useUserList
